Refactor authenticator options to include WebAuthn Level 3 features#101
Refactor authenticator options to include WebAuthn Level 3 features#101shilgapira wants to merge 3 commits intomainfrom
Conversation
|
✅ Code review completed successfully |
There was a problem hiding this comment.
Pull request overview
Refactors WebAuthn Level 3 response customization by moving clientExtensionResults and transports configuration into AuthenticatorOptions, and updates defaults/documentation accordingly.
Changes:
- Add
TransportsandClientExtensionResultstoAuthenticatorOptionsand use them when generating attestation/assertion responses. - Change transport name translation to use an internal transport-name map.
- Replace/adjust tests and update dependencies + README to reflect new behavior.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| utils.go | Updates transport translation logic to use the new transport name map. |
| transport.go | Renames the transport-name map used for encoding transports. |
| authenticator.go | Extends AuthenticatorOptions with transports + client extension results configuration. |
| attestation.go | Uses authenticator options to populate transports and clientExtensionResults in attestation JSON. |
| assertion.go | Uses authenticator options to populate clientExtensionResults in assertion JSON. |
| test/extensions.go | Adds new tests intended to validate default/custom extension results and transports behavior. |
| test/client_extension_results_test.go | Removes prior extension-results-focused tests. |
| README.md | Documents Level 3 support for clientExtensionResults and transports, plus new options usage. |
| go.mod | Updates toolchain version and bumps go-webauthn dependencies. |
| go.sum | Updates dependency checksums to match go.mod changes. |
Comments suppressed due to low confidence (3)
utils.go:74
translateTransportsnow starts withresult := []string{}which may reallocate as it grows. Since the maximum size is known, considermake([]string, 0, len(transports))to avoid extra allocations (even if some entries are filtered out).
func translateTransports(transports []Transport) []string {
result := []string{}
for _, t := range transports {
if name, ok := transportNames[t]; ok {
result = append(result, name)
}
transport.go:14
- Renaming the exported
Transportsmap to unexportedtransportNamesis a breaking public API change for any external callers referencingvirtualwebauthn.Transports. If the intent is to keep the public API unchanged, keepTransportsexported (or provide an exported alias likevar Transports = transportNames).
attestation.go:139 - The defaulting logic
if len(transports) == 0 { transports = []Transport{TransportInternal} }prevents callers from intentionally requesting an explicit emptytransportsarray (valid in WebAuthn L3). Consider defaulting only whenauth.Options.Transports == nil, so an empty but non-nil slice results in an empty JSON array.
transports := auth.Options.Transports
if len(transports) == 0 {
transports = []Transport{TransportInternal}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
🐕 Shuni's Review
Consolidates WebAuthn Level 3 features (clientExtensionResults, transports) from separate *WithExtensions functions into AuthenticatorOptions, cleanly simplifying the public API back to its pre-#80 surface. Default transport narrowed to [internal], translateTransports now safely skips unknown values, and the exported Transports map (added in #80) is correctly unexported.
LGTM — no issues found. Good bones! Woof!
|
@shilgapira refactor makes sense, should be easy to integrate this change, thanks! |
3a98d53 to
51ad84b
Compare
Related Issues
Resolves https://github.com/descope/etc/issues/11944
Related PRs
#80
Description
AuthenticatorOptionsstruct, keeping the library's public API unchanged compared to before.internaltransport.Must